Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow CommandMetadata to be injected into Cli commands #31

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nhinds
Copy link

@nhinds nhinds commented May 11, 2014

This allows HelpOption to be used with commands via Cli.parse.

Without this, attempting to use HelpOption with a command via the Cli class instead of SingleCommand results in a NullPointerException when HelpOption.showHelpIfRequested() is called. This commit allows the pattern git add -h to show help correctly.

This allows HelpOption to be used with commands via Cli.parse
@@ -123,7 +123,7 @@ public C parse(Iterable<String> args)
command.getArguments(),
state.getParsedArguments(),
command.getMetadataInjections(),
ImmutableMap.<Class<?>, Object>of(GlobalMetadata.class, metadata));
ImmutableMap.<Class<?>, Object>of(GlobalMetadata.class, metadata, CommandMetadata.class, command));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should inject CommandGroupMetadata as well -- I did a pull request for this before I discovered yours: #35

@nhinds
Copy link
Author

nhinds commented Nov 6, 2014

@lptr Good idea. I've added something similar to your code from #35 and included a test for it.

@electrum any chance of taking a look at this or #35 and merging one of them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants